/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Recepies;

import javax.naming.ldap.ManageReferralControl;
import mygame.Backbone.GlobalVars;
import mygame.Manager;
import mygame.Object.GameObject;
import mygame.Object.Grabable;
import mygame.Object.Usable;

/**
 *
 * @author Tobi
 */
public class Recepie {

    private String name;
    private Cost[] costs;
    private GameObject object;

    public Recepie(String name) {
        if (name.equals(GlobalVars.OBJECT_NAME_AXT)) {
            costs = new Cost[]{new Cost(GlobalVars.OBJECT_NAME_AST, 1), new Cost(GlobalVars.OBJECT_NAME_STONE, 1)};
            object =  new Usable(name);
        }
    }

    public GameObject build(int count) {
        if (count > 0) {
            boolean check = true;
            for (Cost c : costs) {
                if (!Manager.GetInstance().getPlayer().getInventory().useRessource(c.getName(), c.getCosts() * count, true)) {
                    check = false;
                    break;
                }
            }
            if (check) {
                for (Cost c : costs) {
                    Manager.GetInstance().getPlayer().getInventory().useRessource(c.getName(), c.getCosts() * count, false);
                }
            }
            return object;
        }
        return null;
    }
    
}